# Contributor: Andrew Bell <andrew.bell.ia@gmail.com>
# Maintainer: Andrew Bell <andrew.bell.ia@gmail.com>
pkgname=xerces-c
pkgver=3.2.5
pkgrel=0
pkgdesc="A validating XML parser written in a portable subset of C++"
url="https://xerces.apache.org/index.html"
arch="all"
license="Apache-2.0"
makedepends="cmake curl-dev icu-dev samurai"
subpackages="$pkgname-samples $pkgname-doc $pkgname-dev"
source="$pkgname-$pkgver.tar.gz::https://github.com/apache/xerces-c/archive/v$pkgver.tar.gz"

# secfixes:
#   3.2.5-r0:
#     - CVE-2018-1311

build() {
	local thread_support=-Dthreads:BOOL=ON
	case "$CARCH" in
		s390x) thread_support=-Dthreads:BOOL=OFF ;;
	esac
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX=/usr \
		$thread_support \
		-Dnetwork-accessor=curl \
		-Dmessage-loader=icu \
		-Dtranscoder=icu \
		$CMAKE_CROSSOPTS
	cmake --build build
}

check() {
	cd build
	ctest --output-on-failure
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

samples() {
	pkgdesc="$pkgdesc (compiled samples)"

	amove usr/bin
}

sha512sums="
55bf16456408af7c5aa420a55b27555889fc102a24e86aecb918c165acc80bbc344420687061e020fe223ea04dd78bef929ceedc4b3e24727787f12b8d79b610  xerces-c-3.2.5.tar.gz
"
